package com.moorecat.utils;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Json工具类
 * @author Minglong.Yu
 * @version 1.0 
 * @created Apr 29, 2011 4:04:54 PM
 */
public class JsonUtils {
	
	/**
	 * 转换响应的JSON字符串为ResponseResultBean对象
	 * @param jsonString
	 * @return
	 * @throws JSONException
	 */
	public static ResponseResultBean toResponseResultBean(String jsonString) throws JSONException{
		JSONObject jsonObject = new JSONObject(jsonString);
		ResponseResultBean bean = new ResponseResultBean();
		bean.setStatus(jsonObject.getInt("status"));
		bean.setMsg(jsonObject.getString("msg"));
		if(jsonObject.has("data")==true){
			bean.setData(jsonObject.getJSONArray("data"));
		}
		return bean;
	}
}
